package com.hongdee.scm.accountOfFinance.controller;

import com.hongdee.scm.accountOfFinance.service.ITScmAccountOfFinanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/scm/accountOfFinance")
public class TScmAccountOfFinanceController {

    @Autowired
    private ITScmAccountOfFinanceService itScmAccountOfFinanceService;

    @RequestMapping("/insertTable")
    @ResponseBody
    public Map insertTable(@RequestParam(name = "uid", defaultValue = "") String uid,
                    @RequestParam(name = "token", defaultValue = "") String token
    ) throws Exception {
        Map map = new HashMap();
        //插入t_scm_account_finance
        itScmAccountOfFinanceService.insertToTable(uid);
        map.put("success", true);
        map.put("msg", "分页查询成功！");
        return map;
    }

    @RequestMapping("/insertToTable")
    @ResponseBody
    public Map insertToTable(@RequestParam(name = "uid", defaultValue = "") String uid,
                           @RequestParam(name = "token", defaultValue = "") String token
    ) throws Exception {
        Map map = new HashMap();
        //插入t_scm_stock_form
        itScmAccountOfFinanceService.insertToForm();
        map.put("success", true);
        map.put("msg", "分页查询成功！");
        return map;
    }

    @RequestMapping("/query")
    @ResponseBody
    public Map query(@RequestParam(name = "uid", defaultValue = "") String uid,
                     @RequestParam(name = "token", defaultValue = "") String token,
                     @RequestParam(name = "start", defaultValue = "0") String start,
                     @RequestParam(name = "limit", defaultValue = "10") String limit,
                     @RequestBody Map data
    ) throws Exception {
        Map map = this.itScmAccountOfFinanceService.queryData(data,start,limit);
        map.put("success", true);
        map.put("msg", "分页查询成功！");
        return map;
    }
}
